#include <amxmodx>
#include <umitem>

new PLUGIN_NAME[] 	= "UM Item: Sun Glasses"
new PLUGIN_AUTHOR[] 	= "Cheap_Suit"
new PLUGIN_VERSION[] 	= "1.0"

new bool:g_SunGlasses[33] 
public plugin_init() 
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
	register_item("Sun Glasses", "Cant get flashed", 2200)
	register_event("ScreenFade", "Event_ScreenFade", "be", "4=255", "5=255", "6=255", "7>199")
}

public client_connect(id) {
	g_SunGlasses[id] = false
}

public Enable_Item(id) {
	g_SunGlasses[id] = true
}

public Disable_Item(id) {
	g_SunGlasses[id] = false
} 

public Event_ScreenFade(id)
{
	if(!is_user_connected(id) || !is_user_alive(id)) {
		return PLUGIN_CONTINUE
	}
	
	if(!g_SunGlasses[id]) {
		return PLUGIN_CONTINUE
	}
	
	message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0, 0, 0}, id)
	write_short(~0)
	write_short(~0)
	write_short(1<<12)
	write_byte(0)
	write_byte(0)
	write_byte(0)
	write_byte(0)
	message_end()

	return PLUGIN_CONTINUE
}
